package cz.apnetis.fitweb.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Fitweb implements EntryPoint {

  private static final Integer POSITION_FOOD = Integer.valueOf(0);
  private static final Integer POSITION_FOOD_LIST = Integer.valueOf(1);

  /** Panel which hold food panel */
  private FoodWidget foodEditWidget;
  /** Panel which hold calorie panel */
  private Panel caloriePanel;

  /**
   * This is the entry point method.
   */
  @Override
  public void onModuleLoad() {
    InitializeEverithinig.initializeEverithink();
    final FoodWidget few = new FoodWidget();
    RootPanel.get().add(few);
  }

  public class SelectTable implements SelectionHandler<Integer> {

    @Override
    public void onSelection(final SelectionEvent<Integer> event) {
      if (POSITION_FOOD.equals(event.getSelectedItem())) {
        RootPanel.get("content").clear();
        RootPanel.get("content").add(Fitweb.this.foodEditWidget);
      } else if (POSITION_FOOD_LIST.equals(event.getSelectedItem())) {
        RootPanel.get("content").clear();
      } else {
        RootPanel.get("content").clear();
        RootPanel.get("content").add(Fitweb.this.caloriePanel);
      }
    }
  }
}
